
import {getTicketByOrderNo} from '../../../sers/ticket/ticket';
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
     myTicket:null,
     tittop:app.globalData.tittop+'rpx',
      lbtop:app.globalData.lbtop+'rpx',
      isWindows : app.globalData.isWindows
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options);
    console.log(this.data);
    getTicketByOrderNo(options.orderNo).then(ticket=>{
      // console.log(ticket);
      this.setData({myTicket:JSON.parse(ticket.data.data.posOrderMember)});
      console.log(order);
    }).catch(error=>{
       console.log(error);
    });
  },

  encodeString(str){
    var utf8Array = [];
    for (var i = 0; i < str.length; i++) {
      var charCode = str.charCodeAt(i); // 获得字符的ASCII
      if (charCode < 0x80) {
        utf8Array.push(charCode);
      } else if (charCode < 0x800) {
        utf8Array.push(0xc0 | (charCode >> 6));
        utf8Array.push(0x80 | (charCode & 0x3f));
      } else if (charCode < 0x10000) {
        utf8Array.push(0xe0 | (charCode >> 12));
        utf8Array.push(0x80 | ((charCode >> 6) & 0x3f));
        utf8Array.push(0x80 | (charCode & 0x3f));
      } else {
        utf8Array.push(0xf0 | (charCode >> 18));
        utf8Array.push(0x80 | ((charCode >> 12) & 0x3f));
        utf8Array.push(0x80 | ((charCode >> 6) & 0x3f));
        utf8Array.push(0x80 | (charCode & 0x3f));
      }
    }
    return new Uint8Array(utf8Array);
  },

  base64Encode(inputString) {
    const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/=";
    if(inputString){
      let inputBytes = this.encodeString(inputString);
      let output = "";
      let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
      let i = 0;
 
      while (i < inputBytes.length) {
        chr1 = inputBytes[i++];
        chr2 = inputBytes[i++];
        chr3 = inputBytes[i++];
 
        enc1 = chr1 >> 2;
        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
        enc4 = chr3 & 63;
 
        if (isNaN(chr2)) {
          enc3 = enc4 = 64;
        } else if (isNaN(chr3)) {
          enc4 = 64;
        }
 
        output +=
          keyStr.charAt(enc1) +
          keyStr.charAt(enc2) +
          keyStr.charAt(enc3) +
          keyStr.charAt(enc4);
      }
      let str = output.replaceAll('/','_')
      // console.log('替换str',str);
      str = str.replaceAll('+','-')
      output = str
      return output;
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  toBack(e){
    wx.navigateBack({delta:1});
  }
  
})